<template>
  <div class="app-container">
    <el-form ref="form" :model="form" label-position="top" :rules="rules" size="small" label-width="80px">
      <el-form-item label="关于我们" prop="protocolExplain" style="margin-bottom: 50px">
        <Editor v-model="form.protocolExplain"/>
      </el-form-item>
      <el-form-item label="用户协议" prop="userAgreement" style="margin-bottom: 50px">
        <Editor v-model="form.userAgreement"/>
      </el-form-item>
      <el-form-item label="隐私协议" prop="privacyAgreement" style="margin-bottom: 50px">
        <Editor v-model="form.privacyAgreement"/>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer" style="margin-top: 60px">
      <el-button type="primary" @click="submitForm" :loading="submitLoading">保 存</el-button>
    </div>
  </div>
</template>
<script>
  import {getAppConfig, updateAppConfig} from '@/api/system/appConfig'
  import Editor from '@/components/Editor'

  export default {
    components: {
      Editor
    },
    data() {
      return {
        form: {},
        rules: {},
        title: '',
        submitLoading: false,
      }
    },
    created() {
      getAppConfig(1).then(response => {
        this.form = response.data;
      });
    },
    methods: {
      submitForm: function () {
        this.submitLoading = true
        this.$refs["form"].validate(valid => {
          if (valid) {
            if (this.form.id != undefined) {
              updateAppConfig(this.form).then(response => {
                this.submitLoading = false
                this.msgSuccess("修改成功");
                this.isAdd = false;
                this.init();
              }).catch(err => {
                console.log(err)
              })
            }
          }
        });
      },
    }
  }
</script>
<style>
  .editor {
    height: 600px;
  }
</style>

